Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fork Sync: Update from parent repository #173

Closed
wants to merge 12 commits into from

Conversation

github-actions[bot]
Copy link

@github-actions github-actions bot commented Sep 29, 2023

diff --git a/assets/resources/scriptlets.js b/assets/resources/scriptlets.js
index e22b8950e..22c8574c6 100644
--- a/assets/resources/scriptlets.js
+++ b/assets/resources/scriptlets.js
@@ -3452,6 +3452,29 @@ function preventCanvas(
     });
 }
 
+/******************************************************************************/
+
+builtinScriptlets.push({
+    name: 'multiup.js',
+    fn: multiup,
+    world: 'ISOLATED',
+});
+function multiup() {
+    const handler = ev => {
+        const target = ev.target;
+        if ( target.matches('button[link]') === false ) { return; }
+        const ancestor = target.closest('form');
+        if ( ancestor === null ) { return; }
+        if ( ancestor !== target.parentElement ) { return; }
+        const link = (target.getAttribute('link') || '').trim();
+        if ( link === '' ) { return; }
+        ev.preventDefault();
+        ev.stopPropagation();
+        document.location.href = link;
+    };
+    document.addEventListener('click', handler, { capture: true });
+}
+
 
 /*******************************************************************************
  * 

Prevent usage of specific or all (default) canvas APIs.

Syntax

```text
example.com##+js(prevent-canvas [, contextType])
```

- `contextType`: A specific type of canvas API to prevent (default to all
  APIs). Can be a string or regex which will be matched against the type
  used in getContext() call. Prepend with `!` to test for no-match.

Examples

1. Prevent `example.com` from accessing all canvas APIs

```adblock
example.com##+js(prevent-canvas)
```

2. Prevent access to any flavor of WebGL API, everywhere

```adblock
*##+js(prevent-canvas, /webgl/)
```

3. Prevent `example.com` from accessing any flavor of canvas API except `2d`

```adblock
example.com##+js(prevent-canvas, !2d)
```

References

https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/getContext
pes10k
pes10k previously approved these changes Sep 29, 2023
Copy link
Collaborator

@pes10k pes10k left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adds a new scriptlet that prevents a form of link hijacking

@pes10k pes10k closed this Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants